package com.usaas.search.controller.app.mine;

import com.usaas.common.core.domain.AjaxResult;
import com.usaas.search.controller.app.AppBaseController;
import com.usaas.search.dto.PlatUserPublishDto;
import com.usaas.search.enums.PlatUserPublishEnums;
import com.usaas.search.interceptor.realnameauth.RealNameAuth;
import com.usaas.search.service.IPlatUserPublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户游戏发布Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/app/search/platUserPublish")
public class AppPlatUserPublishController extends AppBaseController {

    @Autowired
    private IPlatUserPublishService platUserPublishService;

    /**
     * 查询客户端用户基础信息分页列表
     */
    //@Log(title = "app端用户游戏发布page查询", businessType = BusinessType.OTHER,operatorType = OperatorType.MOBILE)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatUserPublishDto platUserPublishDto) {
        Long appUserId = getAppUserId();
        platUserPublishDto.setUserId(appUserId);
        return platUserPublishService.queryPage(platUserPublishDto);
    }

    /**
     * 获取用户游戏发布详细信息
     */
    //@Log(title = "app端用户游戏发布详细信息" , businessType = BusinessType.OTHER,operatorType = OperatorType.MOBILE)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return AjaxResult.success(platUserPublishService.queryById(platUserPublishDto.getId()));
    }

    /**
     * 新增用户游戏发布
     */
    //@Log(title = "app端用户游戏发布新增" , businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE)
    @RealNameAuth
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatUserPublishDto platUserPublishDto) {
        Long appUserId = getAppUserId();
        platUserPublishDto.setUserId(appUserId);
        platUserPublishDto.setPassStatus(PlatUserPublishEnums.PASS_STATUS_PENDINGREVIEW.getValueLong());
        platUserPublishService.appAdd(platUserPublishDto);
        return AjaxResult.success();
    }

    /**
     * 删除用户游戏发布
     */
    //@Log(title = "app端用户游戏发布删除" , businessType = BusinessType.DELETE,operatorType = OperatorType.MOBILE)
    @RealNameAuth
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return toAjax(platUserPublishService.removeBatch(platUserPublishDto.getIds()));
    }

}
